<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" xmlns:composite="http://java.sun.com/jsf/composite">

<composite:interface>
	<composite:attribute name="updateElement" />
	<composite:attribute name="oncomplete" />
	<composite:attribute name="selectButtonRendered" default="true" />
	<composite:attribute name="id" />
</composite:interface>

<composite:implementation>
	<p:dataTable id="#{cc.attributes.id}" var="muestra" value="#{muestrasMB.muestras}"
		rowKey="#{muestra.id}" selectionMode="single" emptyMessage="No se han encontrado muestras"
		filteredValue="#{muestrasMB.muestrasFiltrados}" rowsPerPageTemplate="5,10,15" rows="5"
		paginatorPosition="bottom" paginator="true" selection="#{muestrasMB.selectedMuestra}">

		<p:ajax event="rowSelect" listener="#{muestrasMB.rowSelected}" update="#{cc.attributes.id}" />

		<p:column id="nombreCol" filterBy="#{muestra.name}" headerText="Nombre" filterMatchMode="contains">
			<h:outputText value="#{muestra.name}" />
		</p:column>
		<p:column id="descCol" filterBy="#{muestra.descripcion}" headerText="Descripción"
			filterMatchMode="contains">
			<h:outputText value="#{muestra.descripcion}" />
		</p:column>
		<p:column id="fileNameCol" filterBy="#{muestra.fileName}" headerText="Archivo"
			filterMatchMode="contains">
			<h:outputText value="#{muestra.fileName}" />
			<p:overlayPanel for="chartBtn" dynamic="true">
				<p:graphicImage value="#{muestrasMB.dynaImage}" width="300px">
					<f:param name="fileName" value="#{muestra.fileName}"></f:param>
				</p:graphicImage>
			</p:overlayPanel>
			<p:commandButton id="chartBtn" type="button" icon="ui-icon-image" style="margin-left:15px;" />
		</p:column>
		<p:column id="creadoCol" headerText="Creado">
			<h:outputText value="#{muestra.created}">

			</h:outputText>
		</p:column>
		<f:facet name="footer">
			<p:commandButton id="selectMuestraButton"
				rendered="#{cc.attributes.selectButtonRendered}" value="Seleccionar"
				disabled="#{!muestrasMB.rowSelected}"
				update="#{cc.attributes.updateElement}"
				icon="ui-icon-arrowthick-1-n"
				oncomplete="#{cc.attributes.oncomplete}" />
		</f:facet>
	</p:dataTable>
</composite:implementation>

</html>